package org.example.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.pojo.Comment;
import org.example.pojo.PostVO;
import org.example.pojo.User;

@Mapper
public interface PostMapper {
    Page<PostVO> selectPosts(@Param("type") String type, @Param("userId") Long userId);
    int checkLike(@Param("userId") Long userId, @Param("postId") Long postId);
    void insertLike(@Param("userId") Long userId, @Param("postId") Long postId);
    void deleteLike(@Param("userId") Long userId, @Param("postId") Long postId);
    void incrementLikes(@Param("postId") Long postId);
    void decrementLikes(@Param("postId") Long postId);
    Integer getLikes(@Param("postId") Long postId);
    void insertComment(Comment comment);
    User getUser(@Param("userId") Long userId);

    @Insert("insert into posts (user_id, content, images) values (#{userId},#{content},#{imagePath})")
    void addPost(String userId, String content, String imagePath);
}